<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>mamma</title>
<link rel="shortcut icon" href="../image/icon_mamma.ico">

<script src="../js/jquery-2.1.1.js"></script>
<script src="../js/jquery.form.js"></script>
<script src="../js/imgLiquid-min.js"></script>
<script type="text/javascript">

        $(document).ready(function(){
        	
        	var id1= "1";
        	var id2= "2";
        	
        	$.ajax({
        		url: '../admin/baget1.action',
        		type: 'POST',
        		dataType: 'json',
        		data: {id:id1},
        		success:banner1 
        	});
        	
         	$.ajax({
        		url: '../admin/baget2.action',
        		type: 'POST',
        		dataType: 'json',
        		data: {id:id2},
        		success:banner2	       		
        	}); 
        	 
        	$('#bade').on('click',deBanner);
        	$('#bade2').on('click',deBanner1);
        	changBanner();
        	changBanner2();
        	$('div.bannerFrame').imgLiquid();
        	$('div.bannerFrame1').imgLiquid();
        	
        });
     
      function banner1(msg) {	
        	$('#bannerFrame').html('');     	
    		var get = '<div>';
    			if(msg.banner.savedFile == " "){
    				 get += '<img src="../image/profile.png">';
    				}else{ 
    				 get += '<img src="../photoData/'+ msg.banner.savedFile +'">'; 
    			    }      	          
     		    get += '</div>';  
    		 $('#bannerFrame').html(get);
    		 
    		 $('#nowlink').html('');    		
    		 var get = '<a href="' +msg.banner.link+'">'+msg.banner.link+'</a>';
    		 /* var get = '<div>' +msg.banner.link+'</div>';   */  		
     		 $('#nowlink').html(get);    				
    	} 
      
      function banner2(msg1) {	
      	$('#bannerFrame1').html('');     	
  		var get = '<div>';
  			if(msg1.banner.savedFile == " "){
  				 get += '<img src="../image/profile.png">';
  				}else{ 
  				 get += '<img src="../photoData/'+ msg1.banner.savedFile +'">'; 
  			    }      	          
   		    get += '</div>';  
  		 $('#bannerFrame1').html(get);
  		 
  		 $('#nowlink1').html('');    		
  		 var get = '<a href="' +msg1.banner.link+'">'+msg1.banner.link+'</a>';    		
   		 $('#nowlink1').html(get);    				
  	} 
       
        function changBanner() {
        	$('#form1').ajaxForm({
              beforeSubmit: function() {
              }
              , error: function(){
                 alert('error');
              }
              , success: function(json){
            	$('div.bannerFrame').imgLiquid();
              	location.href='../admin/goAdBannerPage.action';
                }
              , clearForm: true
           });
		}
        
        function changBanner2() {
        	$('#form3').ajaxForm({
              beforeSubmit: function() {
              }
              , error: function(){
                 alert('error');
              }
              , success: function(json){
              	
              	location.href='../admin/goAdBannerPage.action';
                }             
              , clearForm: true
           });
		}
        
        function deBanner() {	
        	
         form2	= $("#form2").serialize(),

        	$.ajax({
        		url: 'bade.action',
        		type: 'POST',
        		dataType: 'json',
        		data: form2,
        		success: saveOK
        	});
        }
        
        function deBanner1() { 
         form4	= $("#form4").serialize(),

     	$.ajax({
     		url: 'bade.action',
     		type: 'POST',
     		dataType: 'json',
     		data: form4,
     		success: saveOK
     	});
        
    	}
     
    	function saveOK() {	
    		location.href='../admin/goAdBannerPage.action';
    	}
  </script>

<style type="text/css">
table{
	border: thin; 
	border-color: #BDBDBD;
	border-style: solid;
	table-layout: auto;	
}
.adhead{border: 0px;}
.mainframe{border: 0px;}
div.bannerFrame {
	
	
	height: 300px;
	width: 350px;
		
	position: relative;
	margin-left: 20px;
	margin-top: 5px; 
}
div.bannerFrame img {
	max-height: 300px;
	max-width: 350px;
}

div.bannerFrame1 {
	
	height: 300px;
	width: 350px;
		
	position: relative;
	margin-left: 20px;
	margin-top: 5px; 
}
div.bannerFrame1 img {
	
	max-height: 300px;
	max-width: 350px;
}

.bannerChange1{
  margin-left: 5px;
}
.bannerChange{
  margin-left: 5px;
}

</style>



</head>

<body topmargin="0"  leftmargin="0" rightmargin="0">
<table id="adhead" class="adhead" border="0" width="100%" height="100px" style="text-align: center;background-color: #EAEAEA;">
<tr>
<td>	
	<a href="../admin/goNoticelistPage.action">공지 관리</a>
	<a href="../admin/goJusalistPage.action">백신 알림</a>
	<a href="../admin/goMemberlistPage.action">회원 목록 보기</a>
	<a href="../admin/goAdBannerPage.action">광고 관리</a>
	<a href="../account/logout.action">로그아웃</a>
</td>
</tr></table>
<br>
<table style="margin:0 auto;" id="mainframe"  class="mainframe">
<tr>
<td>
<table width="400px" height="600px">
	<tr>
		<td style="background-color: #EAEAEA;">
			<div class="updateTitle">
				<span class="title">캘린더에 들어갈 배너</span>
			</div>
		</td>
	</tr>	
			
	<tr>
		<td>
			<div class="bannerFrame" id="bannerFrame"></div>
		</td>
	</tr>
	
	<tr>
		<td style="background-color: #EAEAEA;">	
			<div>현재 링크</div><div id="nowlink"></div>
			</td>
	</tr>		
		
	<tr>
		<td>	
			<div class="bannerChange">
			    <form id="form1"  method="post" enctype="multipart/form-data" action="baup.action"> 
			        <div>배너 변경 :
			        <input type='file' id="upload" name="upload"/>
			        </div>			        
			        <div>링크 입력 :
			        <input id="link"  name="link" type="text" size="35px" value="http://">
			        </div>
					<input type=hidden id="id" name="id" value="1">
					<br><input type="submit" value="배너 입력">
			    </form>	    
		    <br>
				 <form id="form2"> 
				 	<input type=hidden id="link" name="link" value=" ">
					<input type=hidden id="id" name="id" value="1">
					<input type="submit"  id="bade" value="배너 삭제">
			     </form>
			</div>
		</td>
	</tr> 
</table>
</td>

<td width="50px"></td>

<td>
<table width="400px" height="600px">
	<tr>
		<td style="background-color: #EAEAEA;">
			<div class="updateTitle1">
				<span class="title1">다른 화면에 들어갈 배너</span>
			</div>
		</td>
	</tr>	
		
	<tr>
		<td>	
			<div class="bannerFrame1" id="bannerFrame1"></div>
			</td>
	</tr>	
	
	<tr>
		<td style="background-color: #EAEAEA;">	
			<div>현재 링크 </div><div id="nowlink1"></div>
		</td>
	</tr>	
	
	<tr>
		<td>	
			<div class="bannerChange1">
			    <form id="form3"  method="post" enctype="multipart/form-data" action="baup.action"> 
			        <div>배너 변경 :
			        <input type='file' id="upload" name="upload"/>
			        </div>			        
			        <div>링크 입력 :
			        <input id="link"  name="link" type="text" size="35px" value="http://">
			        </div>
					<input type=hidden id="id" name="id" value="2">
					<br><input type="submit" value="배너 입력">
			    </form>
			    <br>
				 <form id="form4"> 
				 	<input type=hidden id="link" name="link" value=" ">
					<input type=hidden id="id" name="id" value="2">
					<input type="submit" id="bade2" value="배너 삭제">
			    </form>
			 </div> 
		</td>
	</tr>	
	 
</table>
</td>
</tr>
</table>



</body>
</html>